#include<bits/stdc++.h>
using namespace std;
struct edge {
    int to, w;
};
vector<vector<edge>>graph(501);
int people[501];
int path[501];
int f[501];
int cost[501];
int dist[501];
bool visited[501] = { false };
int main(void)
{
    for (int i = 0; i <= 500; i++)
    {
        dist[i] = 100000;
        path[i] = -1;
    }
    int n, m, start, end;
    cin >> n >> m >> start >> end;
    f[start] = 1;
    dist[start] = 0;
    for (int i = 0; i < n; i++)
    {
        cin >> people[i];
    }
    for (int i = 0; i < m; i++)
    {
        int from, to, w;
        edge e;
        cin >> from >> to >> e.w;
        e.to = to;
        graph[from].push_back(e);
        e.to = from;
        graph[to].push_back(e);

    }
    int current = start;
    cost[current] = people[current];
    for (int i = 0; i < n; i++)
    {
        visited[current] = true;
        for (int j = 0; j < graph[current].size(); j++)
        {
            int to = graph[current][j].to;
            int newdist = dist[current] + graph[current][j].w;
            int newpeople = cost[current] + people[to];
            if (newdist < dist[to])
            {
                dist[to] = newdist;
                f[to] = f[current];
                path[to] = current;
                cost[to] = newpeople;
            }
            else if (newdist == dist[to])
            {
                f[to] += f[current];
                if (newpeople > cost[to])
                {
                    path[to] = current;
                    cost[to] = newpeople;
                }
            }
        }
        int M = 100000;
        for (int j = 0; j < n; j++)
        {
            if (dist[j] < M && visited[j] == false)
            {
                M = dist[j];
                current = j;
            }
        }
    }
    cout << f[end] << " " << cost[end] << endl;
    vector<int>result;
    result.push_back(end);
    while (path[end] != -1)
    {
        result.push_back(path[end]);
        end = path[end];
    }
    for (int i = 0; i < result.size(); i++)
    {
        if (i)
            cout << " ";
        cout << result[result.size() - 1 - i];
    }
}